package main

import (
	"fmt"
	"strings"
)

func main() {

	fmt.Printf("%q\n", strings.Split("foo,bar,baz", ","))      //不会带有分隔符号
	fmt.Printf("%q\n", strings.SplitAfter("foo,bar,baz", ",")) //带有分割符号
	fmt.Printf("%q\n", strings.SplitN("foo,bar,baz", ",", 2))  //所有后面带N的有第三个参数 说明分为几个单元

	fmt.Println("==================================================")

	fmt.Printf("%q\n", strings.Split("a,b,c", ","))
	fmt.Printf("%q\n", strings.Split("a man a plan a canal panama", "a "))
	fmt.Printf("%q\n", strings.Split(" xyz ", "")) //这相当于按字符分
	fmt.Printf("%q\n", strings.Split("", "Bernardo O'Higgins"))

	fmt.Println("==================================================")

	fmt.Printf("%q\n", strings.Split("112345678915        810355839022517280               #", " "))
	//按空格分的时候有这样的问题 空格也算一个单元  所以不想要空格 还得用strings.Fields 你将会得到你想要的["112345678915" "810355839022517280" "#"]

}

/*
输出结果
["foo" "bar" "baz"]
["foo," "bar," "baz"]
["foo" "bar,baz"]
==================================================
["a" "b" "c"]
["" "man " "plan " "canal panama"]
[" " "x" "y" "z" " "]
[""]
==================================================
["112345678915" "" "" "" "" "" "" "" "810355839022517280" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "#"]
*/
